package ar.edu.utn.frba.tacs.warnes.bd;

import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;

public class MyDbManager{

	String commandShell;
	
	public void levantarDB() {
		correrComando("java -cp hsqldb.jar org.hsqldb.Server");
		correrComando("java -cp hsqldb.jar org.hsqldb.Server");
	};
	
	public boolean correrComando(String command){				
						    
		    
			this.commandShell = "cmd.exe /C " + command; 
			
			// Lanzamos el proceso	
			try 
			{ 
			Process proc = Runtime.getRuntime ().exec (this.commandShell); 
			BufferedReader brStdOut = new BufferedReader(new InputStreamReader(proc.getInputStream())); 
			BufferedReader brStdErr = new BufferedReader(new InputStreamReader(proc.getErrorStream())); 
			String str=null; 
			while ((str = brStdOut.readLine())!=null) 
			{ 
			System.out.println (str); 
			} 
			brStdOut.close(); 
			brStdErr.close(); 
			} 
			catch (IOException eproc) 
			{ 
			System.out.println ("Error to execute the command : "+eproc); 
			return false; 
			} 
			return true; 
	}
		
}
